<?php
// +----------------------------------------------------------------------
// | ThinkPHP5.0 [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 郉仲生 <540426628@QQ.com>
// +----------------------------------------------------------------------
// | Date：2017年6月28日
// +----------------------------------------------------------------------
namespace app\admin\controller;
class Lea extends Common
{
	public function lst()
	{
		/*
		if(request()->isPost()){
            $sorts=input('post.');
            $lea=new LeaModel();
            foreach ($sorts as $k => $v) {
                $lea->update(['id'=>$k,'sort'=>$v]);
            }
            $this->success('更新排序成功！',url('lst'));
            return;
        }
         $leares=LeaModel::order('id desc')->paginate(4);
        $this->assign('leares',$leares);
*/

		/*
		$artRes=db('lea')->field('a.*,u.uname')->alias('a')->join('bk_user u','a.uid = u.uid')->order('id desc')->paginate(3);
		$this->assign([
			'artRes'=>$artRes,
		]);
		*/
//		var_dump($artRes);
//		die;
//
//		return view();
	}


	public function add()
	{
        if(request()->isPost())
        {
            $data=input('post.');
            $data['addtime']=time();
            
            $validate=validate('lea');
            if(!$validate->scene('add')->check($data))
            {
                $this->error($validate->getError());
            }
            $add=db('lea')->insert($data);
            if($add)
            {
                $this->success('添加留言成功！','lst');
            }else{
                $this->error('添加留言失败！');
            }
            return;
        }
        
        return view();
    }

}